<?php
 
class XForm{
 
/*	$xf = new XForm();
 *	$xf->inputText('Nombre', 'nombre', 'prueba!!!');
 *	$xf->dropDown('plan_pago', 'Plan de Pago', $q->getCarrerasImportes(),$default);
 *	
 */

//	bottonera
	public function buttons($buttonGR,$buttonGN,$buttonGE,$buttonR){
	?>
		<div class="xcrud-top-actions btn-group">
	<?php
			if($buttonGR){
				echo '<a id="buttonGR" class="btn btn-primary xcrud-action">Guardar &amp; Regresar</a>';
			}
			if($buttonGN){
				echo '<a id="buttonGN" class="btn btn-default xcrud-action">Guardar &amp; Nuevo</a>';
			}
			if($buttonGE){
				echo '<a id="buttonGE" class="btn btn-default xcrud-action">Guardar &amp; Editar</a>';
			}
			if($buttonR){
				echo '<a id="buttonR" class="btn btn-warning xcrud-action">Regresar</a>';
			}
	?>			
		</div>
		<br/><br/>	
	<?php	
	}
	
//start
	public function formStart(){
	?>
		<div class="xcrud-view">
		<div class="form-horizontal">
	<?php       
  	}
  
//stop
	public function formStop(){
	?>
	  	</div>
	  	</div>
	<?php
	}
    
//inputText
	public function inputText($id,$labelText,$value){
	?>
		<div class="form-group">
			<label class="control-label col-sm-3"><?php echo $labelText?></label>
			<div class="col-sm-9">
				<input class="xcrud-input form-control" type="text" data-type="text" id="<?php echo $id?>" value="<?php echo $value?>" name="<?php echo $id?>" maxlength="200">
			</div>
		</div>  	
  <?php       
	}
   	
    
 //labelForm
  public function labelForm($id,$text,$type,$h){
  	/*
  	 * $text = default,primary,success,info,warning,danger
  	 */
  	
  	?>
		<div class="form-group">
			<label class="control-label col-sm-3"></label>
			<div class="col-sm-9">
			<h<?php echo $h?>><span class="label label-<?php echo $type?>"><?php echo $text?></span></h<?php echo $h?>>
			</div>
		</div>
<?php       
    }
	
    //labelForm
    public function label($id,$text,$type,$h){
    	/*
    	 * $text = default,primary,success,info,warning,danger
    	 */
    		echo '<h'.$h.'><span class="label label-'.$type.'">'.$text.'</span></h'.$h.'>';       
        }
        
//dropDown
  public function dropDown($id,$labelText,$values,$default,$optionSelec){
?>
		<div class="form-group">
			<label class="control-label col-sm-3"><?php echo $labelText?></label>
			<div class="col-sm-9">
				<select class="xcrud-input form-control form-control" data-type="select" id="<?php echo $id?>" name="<?php echo $id?>" maxlength="11">
				<?php
				if($optionSelec){
					echo '<option value="">- SELECCIONAR -</option>';
				}
				foreach ($values as $row) {
					if($default == $row->value){
						echo '<option selected value="'.$row->value.'">'.$row->label.'</option>';
					}
					else{
						echo '<option value="'.$row->value.'">'.$row->label.'</option>';
					}
					
				}
				?>
				</select>
			</div>
		</div>
<?php 
  }

//setError FALTA
  public function setError($id,$true){
  	if($true){
 ?>
	 <script>
		$(document).ready(function(){
			$("#borrar").css("box-shadow", "0 0 1px red, 0 0 3px red");
			$("#borrar").css("background", "#FFEBEB");
		})
	</script>
 <?php 
  	}
  	else{
  ?>
  		<script>
  		$(document).ready(function(){
  			$("#borrar").css("box-shadow", "");
  			$("#borrar").css("background", "");
  		})
  		</script>
  <?php
  	}
  }

//validEmpty
	public function validEmpty($id){
?>
		<script>
			var campos = ["borrar","plan_pago"];
			$("#buttonGR").click(function(){
				for (i = 0; i < campos.length; i++) {
					
					if( $(campos[i]).val() == ""){
						$(campos[i]).css("box-shadow", "0 0 1px red, 0 0 3px red");
						$(campos[i]).css("background", "#FFEBEB");
					}
					else{
						$(campos[i]).css("box-shadow", "");
						$(campos[i]).css("background", "");
					}
				}
			});
		</script>
<?php	
	}
}
?>

<script type="text/javascript">
function getValue(){
	//return $("#plan_pago").val();
	return $('#plan_pago :selected').val()
}
// $.getValue = function(){
// 	$(document).ready(function(){
// 		return '1';
// 	})
// }

function XJQmessage(mensaje,tipo){
	Xcrud.show_message($(".xcrud-overlay"), mensaje, tipo);
}
function PJQmessage(mensaje,tipo){
	Xcrud.show_message($("xplus-message"), mensaje, tipo);
}
</script>